package org.opens;

import ch.qos.logback.core.db.DBHelper;
import org.opens.config.ConditionalConfig;
import org.opens.config.properties.Car;
import org.opens.entity.City;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.interceptor.CacheAspectSupport;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
public class SpringDemoApplication {

    public static void main(String[] args) {
        // run方法的返回值是IOC容器
        ConfigurableApplicationContext context = SpringApplication.run(SpringDemoApplication.class, args);

        boolean flag1 = context.containsBean("city4");
        boolean flag2 = context.containsBean("city3User");
        System.out.println(flag1);
        System.out.println(flag2);

        boolean flag11 = context.containsBean("helloWorld057");
        boolean flag12 = context.containsBean("prototypeBean057");

        System.out.println("ImportResourceConfig flag11:" + flag11);
        System.out.println("ImportResourceConfig flag12:" + flag12);

        Car carConfig = context.getBean("car", Car.class);
        // carConfig: Car(brand=BYD, price=52000)
        System.out.println("carConfig: " + carConfig);

        System.out.println(context.getBeanNamesForType(CacheAspectSupport.class).length);
    }

}
